package com.guns.dome1.web;


import com.guns.dome1.service.IUserService;
import com.guns.dome1.vo.req.ReqUserVo;
import com.guns.dome1.vo.resp.RespBaseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserControler {


    //逻辑层接口
    @Autowired
    private IUserService userService;


    //登录
    @ResponseBody
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public RespBaseVo login(@RequestBody ReqUserVo reqUserVo) {
        return userService.login(reqUserVo);
    }

    //注销
    @ResponseBody
    @RequestMapping(value = "/logout", method = RequestMethod.POST)
    public RespBaseVo logout(@RequestBody ReqUserVo reqUserVo) {
        return userService.logout(reqUserVo);
    }


    //查询所有
    @ResponseBody
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public RespBaseVo list(@RequestBody ReqUserVo reqUserVo) {
        return userService.list(reqUserVo);
    }

    //添加（一个）
    @ResponseBody
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public RespBaseVo add(@RequestBody ReqUserVo reqUserVo) {
        return userService.add(reqUserVo);
    }

    //修改
    @ResponseBody
    @RequestMapping(value = "/edit", method = RequestMethod.PUT)
    public RespBaseVo edit(@RequestBody ReqUserVo reqUserVo) {
        return userService.edit(reqUserVo);
    }

    //删除
    @ResponseBody
    @RequestMapping(value = "/del", method = RequestMethod.DELETE)
    public RespBaseVo del(@RequestBody ReqUserVo reqUserVo) {
        return userService.del(reqUserVo);
    }


}
